package com.example.service;

import com.example.entity.Item;
import com.example.mapper.ItemMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemService {
    @Resource
    private ItemMapper itemMapper;

    public PageInfo<Item> selectPage(Integer currentPage, Integer pageSize, Item item,Integer businessId) {
        PageHelper.startPage(currentPage, pageSize);
        List<Item> list = itemMapper.selectAll_bus(item,businessId);
        return PageInfo.of(list);

    }

    public PageInfo<Item> selectPage(Integer currentPage, Integer pageSize, Item item) {
        PageHelper.startPage(currentPage, pageSize);
        List<Item> list = itemMapper.selectAll(item);
        return PageInfo.of(list);

    }

    public void addItem(Item item) {
        itemMapper.addItem(item);
    }

    public void updateItem(Item item) {
        itemMapper.updateItem(item);
    }


    public Item selectById(Integer id) {
        return itemMapper.selectById(id);
    }

    public PageInfo<Item> selectPageByCid(Integer currentPage, Integer pageSize, Item item, Integer cid) {
    PageHelper.startPage(currentPage, pageSize);
    List<Item> list = itemMapper.selectPageByCid(item,cid);
    return PageInfo.of(list);
    }
}
